{% extends "wx/base.html" %}
{% load static %}
{% load jsonify %}


{% block page_content %}

<script type="text/javascript">



//    $(function(){
//        ln.history_handle({
//            init:{crt_view:'main'},
//            handler:function(state){
//                if(state.crt_view) {
//                    table.crt_view = state.crt_view
//                }
//            }
//        })
//    })


    crt_view = 'main'

    main_logic={
        el:'#there',
        data:{
            crt_view:crt_view,
            in_wx_agent:in_wx_agent,
            ln:ln,
            page_label:page_label,
            is_show_menu:false,
        },
        mixins:[table_fun,scroll_loader],
        mounted:function(){
            var self=this
//            Vue.nextTick(function(){
//                self.$refs.scroller.refresh()
//            })

            bus.$on('menu_click',function(){
                self.is_show_menu=true
            })
        },
        methods:{
            goto:function(url){
                location=url
            },
            ge_edit:function(pk){
                location= ex.template('{engine_url}/{page_name}.edit?pk={pk}',{engine_url:engine_url,page_name:page_name,pk:pk})
            },
            switch_to:function(name){
                history.pushState({view:name},'',ex.appendSearch({crt_view:name}))
                this.crt_view=name
            },
            back:function(){
                location = document.referrer
            },

        }
    }


        $(function(){
           table= new Vue(main_logic)
        })
</script>

<style>
    /*.total-wrap{*/
        /*height: 100vh;*/
        /*position: relative;*/
    /*}*/

</style>

{% block extra_head %}
{% endblock %}

<div id="there" v-cloak class="flex-grow"  style="position: relative;">


    <!--<button @click="switch_to('search')">过滤</button>-->

    <div class="flex-v scroll-wraper">

        {% block table_head %}

            <transition name="slide">
                <div v-show="crt_view=='search'" class="slide-win">
                    <title-bar :with_back="true" title="筛选"></title-bar>
                    <com-filter :row_filters="row_filters" :search_args="search_args" :search_tip='search_tip'></com-filter>

                    <div class="weui-btn-area">
                        <a class="weui-btn weui-btn_primary" href="javascript:" @click='search()' style="width: 50%;">
                            <i class="fa fa-search" aria-hidden="true"></i>
                        </a>
                    </div>

                </div>
            </transition>


            <transition name="fade">
                <modal id="pop-menu" v-show="is_show_menu" @click.native="is_show_menu=false">

                    <div class="weui-actionsheet__menu up-menu" @click.stop="" style="width: 80vw;">
                        <div class="weui-actionsheet__cell" @click="add_new();is_show_menu=false" v-if="can_add">新建</div>
                        <div class="weui-actionsheet__cell" @click="del_item();is_show_menu=false" v-if="can_del &&selected.length>0">删除选中</div>
                        <div class="weui-actionsheet__cell" @click="ln.pushState({crt_view:'search'});is_show_menu=false" v-if="can_search">排序过滤</div>
                    </div>
                    <div class="weui-actionsheet__cell">
                        <div class="weui-actionsheet__cell" @click="is_show_menu=false">取消</div>
                    </div>

                </modal>
            </transition>

            <!--<div class="weui-cells__title" v-text="page_label"></div>-->
        {% endblock %}


        <!--<scroll-wraper class="flex-grow" ref="scroller" :down_text='get_down_text()' @down_out_border="load_next_page()" style="margin-bottom: 5em;">-->
            {% block item_view %}
                <div class="weui-cells">
                    <a class="weui-cell weui-cell_access" href="javascript:;" v-for="row in rows">
                        <div class="weui-cell__hd" style="padding: 0 1em 0 0.3em;">
                            <!--<input type="checkbox" v-model="selected" :value="row.pk"  />-->
                            <com-check-box v-model="selected" :value="row.pk"></com-check-box>
                        </div>
                        <div class="weui-cell__bd" @click="ge_edit(row.pk)">
                            <p v-text="row._label"></p>
                        </div>
                        <div class="weui-cell__ft">
                        </div>
                    </a>
                </div>
            {% endblock %}
        <!--</scroll-wraper>-->
    </div>





</div>





{% endblock %}